//
//  ExampleColoredNaviController.m
//  MultiSegmentControl
//
//  Created by ET|冰琳 on 16/7/4.
//  Copyright © 2016年 Ice Butterfly. All rights reserved.
//

#import "ExampleColoredNaviController.h"
#import "MultiSegmentController.h"
#import "NavigationSegmentController.h"
#import "TestTableViewController.h"


@implementation ExampleColoredNaviController


- (void)viewDidLoad{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];

    NSArray *colors = @[[UIColor redColor], [UIColor orangeColor], [UIColor yellowColor]];
    NSMutableArray *coloredVCS = [NSMutableArray arrayWithCapacity:colors.count];
    
    for (UIColor *color in colors) {
        TestTableViewController *viewController = [TestTableViewController new];
        viewController.view.backgroundColor = color;
        [coloredVCS addObject:viewController];
    }
    
    BIMultiSegmentControl *multi = [[EqualWSegmentControl alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/3*2, 44.f) titles:@[@"社区",@"福利",@"活动"]];
    self.navigationItem.titleView = multi;
    multi.sameIgnore = true;
    multi.selectIndex = 0;
    multi.bottomlineView.hidden = NO;
    multi.backgroundColor = [UIColor whiteColor];
    [multi addVerticalLines];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.navigationItem.backBarButtonItem = nil;
    
    MultiSegmentController *controller = [[MultiSegmentController alloc] initWithSegmentControl:multi viewControllers:coloredVCS];
    
    [coloredVCS enumerateObjectsUsingBlock:^(TestTableViewController *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.segmentController = controller;
    }];
    controller.segmentLocation = MultiSegmentLocationNone;
    [self addChildViewController:controller];
    [self.view addSubview:controller.view];
//    controller.scrollContainer.scrollEnabled = false;
    
    [controller didMoveToParentViewController:self];
    
}


@end
